#include "EntityExplosion.h"
#include "ComponentManager.h"

CEntityExplosion::CEntityExplosion(int indexAnimation, const CVector2i& position, int sound):
									CWorldEntity(indexAnimation, position, false),m_idAnimSprite(-1), m_animTime(-1),
									m_animationOver(false), m_sound(sound), m_soundPlayed(false){}

CEntityExplosion::~CEntityExplosion(){}

void CEntityExplosion::doUpdate(void)
{
	if(!m_soundPlayed)
	{
		CM.AUDIO().playSound(m_sound);
		m_soundPlayed = true;
	}
}

void CEntityExplosion::doRender(void)
{
	m_animationOver = CM.VISU().displayAnimation(m_indexGfx, m_position, &m_idAnimSprite, &m_animTime);
	if(m_animationOver)
	{
		m_animationOver = false;
		m_active = false;
		resetAnimationData();
	}
}

void CEntityExplosion::resetAnimationData(void)
{
	m_idAnimSprite=-1;
	m_animTime=-1;
}
